package com.hexus.eve.entities;

import java.util.Locale;
import java.util.Map;

import javax.persistence.Entity;
import javax.persistence.GeneratedValue;
import javax.persistence.Id;
import javax.persistence.Table;

/**
 * Class describes blueprint which belongs to a character.
 * Consider it an instance of type-blueprint, an object of blueprint type which a character owns.
 *  
 * @author Mikhail_Berastau
 */
@Entity
@Table(name="characterBlueprints")
public class CharacterBlueprint extends EveEntity {
	private static final String DB_TABLE_NAME = "dbo.invTypes";
	private static final String NAME_COLUMN = "typeName";

	
	@Id	
	@GeneratedValue
	private Integer id;
	
	private Integer blueprintID; //id of Type which describes the blueprint
	private String blueprintName; //this field is a duplication of the Type name field. Added for performance/convenience reason.
	
	private Integer characterID; //owner of blueprint
	private Integer quantity = 1; //number of such blueprints (character can own several similar blueprints)
	
	@Override
	public Integer getId() {
		return id;
	}

	@Override
	public void translate(Map<String, String> translationValues, Locale locale) {
		if(translationValues.containsKey(NAME_COLUMN)) {
			setName(translationValues.get(NAME_COLUMN));
		}	
	}

	@Override
	public String getName() {
		return blueprintName;
	}

	@Override
	public String getTableName() {
		return DB_TABLE_NAME;
	}
	
	/**
	 * Gets blueprint ID which this characterBlueprint relates to.<br/>
	 * <i>Note: This ID is internal (producteve DB) ID, not the EVE blueprint ID!</i>
	 * @param blueprintID
	 */
	public Integer getBlueprintID() {
		return blueprintID;
	}
	
	/**
	 * Sets blueprint ID which this characterBlueprint relates to.<br/>
	 * As far as all blueprints are Types, id must exist in invTypes table.<br/>
	 * <i>Note: This ID is internal (producteve DB) ID, not the EVE blueprint ID!</i>
	 * @param blueprintID
	 */
	public void setBlueprintID(Integer blueprintID) {
		this.blueprintID = blueprintID;
	}

	public Integer getQuantity() {
		return quantity;
	}

	public void setQuantity(Integer quantity) {
		this.quantity = quantity;
	}

	public String getBlueprintName() {
		return blueprintName;
	}

	public void setName(String blueprintName) {
		this.blueprintName = blueprintName;
	}
	
	/**
	 * Sets internal (producteve DB) character ID<br/> 
	 * <i>Note: Do not mix it up with EVE character ID!</i> 
	 */
	public void setCharacterID(Integer characterID) {
		this.characterID = characterID;
	}
	
	/**
	 * Gets internal (producteve DB) character ID<br/> 
	 * <i>Note: Do not mix it up with EVE character ID!</i> 
	 */
	public Integer getCharacterID() {
		return characterID;
	}

}
